#include "Director.h"
Director * Director::m_pDirector = NULL;

Director::Director(void)
	:m_Input(NULL), m_Txt(NULL), m_Sound(NULL),
	 m_Scene(NULL), m_d3d9(NULL)
{
}

Director::~Director(void)
{
	delete m_Scene;
	delete m_Sound;
	delete m_Txt;
	delete m_d3d9;
	delete m_Input;
}
void Director::InitInput(HWND hWnd, HINSTANCE hInstance)
{
	m_Input = new InputManager();
	m_Input->Init(hWnd, hInstance);
}
void Director::init(void)
{
	m_Txt = new TextureManager();
	m_Sound = new SoundManager();
	m_Scene = new SceneManager();
}
HRESULT Director::InitD3D9(HWND hWnd, int nWidth, int nHeight, bool bFullScreen)
{
	m_d3d9 = new D3D9();
	if(SUCCEEDED(m_d3d9->InitD3D9(hWnd, nWidth, nHeight, bFullScreen)))
	{
		m_d3d9->ClearScene();
		this->init();
		return S_OK;
	}
	return E_FAIL;
}
void Director::Update()
{
	m_Input->Update();
	m_d3d9->BeginPaint();
	if( m_Scene->checkNextScene() )
		m_Scene->changeScene();
	m_Scene->GetNowScene()->Update();
	m_d3d9->EndPaint();
}

Director * Director::sharedDirector()
{
	if(m_pDirector==NULL)
	{
		m_pDirector = new Director();
	}
	return m_pDirector;
}